package com.timmy.test1.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.appcompat.widget.AppCompatTextView;
import com.timmy.test1.R;

/**
 * Created by timmy on 2020/5/6.
 */
public class KeyView extends AppCompatTextView {

    private float continuousFrequency;

    private boolean isContinuous;

    private boolean isFling;

    private boolean isLongPress;

    private boolean isPressDown;

    Context mContext;

    int scanCode;

    public KeyView(Context paramContext) {
        super(paramContext);
        this.mContext = paramContext;
    }

    public KeyView(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
        this.mContext = paramContext;
        init(paramAttributeSet);
    }

    public KeyView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) {
        super(paramContext, paramAttributeSet, paramInt);
        this.mContext = paramContext;
        init(paramAttributeSet);
    }

    private void init(AttributeSet paramAttributeSet) {
        TypedArray typedArray = this.mContext.obtainStyledAttributes(paramAttributeSet, R.styleable.KeyView);
        this.scanCode = typedArray.getInt(R.styleable.KeyView_scanCode, 0);
        this.isLongPress = typedArray.getBoolean(R.styleable.KeyView_isLongPress, false);
        this.isFling = typedArray.getBoolean(R.styleable.KeyView_isFling, false);
        this.isContinuous = typedArray.getBoolean(R.styleable.KeyView_isContinuous, false);
        this.continuousFrequency = typedArray.getFloat(R.styleable.KeyView_continuousFrequency, 0.1F);
        typedArray.recycle();
    }

    public float getContinuousFrequency() {
        return this.continuousFrequency;
    }

    public int getScanCode() {
        return this.scanCode;
    }

    public boolean isContinuous() {
        return this.isContinuous;
    }

    public boolean isFling() {
        return this.isFling;
    }

    public boolean isLongPress() {
        return this.isLongPress;
    }

    public boolean isPressDown() {
        return this.isPressDown;
    }

    @Override
    public boolean onTouchEvent(MotionEvent paramMotionEvent) {
        return super.onTouchEvent(paramMotionEvent);
    }

    public void setContinuous(boolean paramBoolean) {
        this.isContinuous = paramBoolean;
    }

    public void setContinuousFrequency(float paramFloat) {
        this.continuousFrequency = paramFloat;
    }

    public void setFling(boolean paramBoolean) {
        this.isFling = paramBoolean;
    }

    public void setLongPress(boolean paramBoolean) {
        this.isLongPress = paramBoolean;
    }

    public void setPressDown(boolean paramBoolean) {
        this.isPressDown = paramBoolean;
    }

    public void setScanCode(int paramInt) {
        this.scanCode = paramInt;
    }
}
